﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

namespace BlobStoring.Database.Host.ConsoleApp.ConsoleApp.Migrations;

public partial class Initial : Migration
{
    protected override void Up(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.CreateTable(
            name: "AbpBlobContainers",
            columns: table => new {
                Id = table.Column<Guid>(nullable: false),
                ExtraProperties = table.Column<string>(nullable: true),
                ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
                TenantId = table.Column<Guid>(nullable: true),
                Name = table.Column<string>(maxLength: 128, nullable: false)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpBlobContainers", x => x.Id);
            });

        migrationBuilder.CreateTable(
            name: "AbpBlobs",
            columns: table => new {
                Id = table.Column<Guid>(nullable: false),
                ExtraProperties = table.Column<string>(nullable: true),
                ConcurrencyStamp = table.Column<string>(maxLength: 40, nullable: true),
                ContainerId = table.Column<Guid>(nullable: false),
                TenantId = table.Column<Guid>(nullable: true),
                Name = table.Column<string>(maxLength: 256, nullable: false),
                Content = table.Column<byte[]>(maxLength: 2147483647, nullable: true)
            },
            constraints: table =>
            {
                table.PrimaryKey("PK_AbpBlobs", x => x.Id);
                table.ForeignKey(
                    name: "FK_AbpBlobs_AbpBlobContainers_ContainerId",
                    column: x => x.ContainerId,
                    principalTable: "AbpBlobContainers",
                    principalColumn: "Id",
                    onDelete: ReferentialAction.Cascade);
            });

        migrationBuilder.CreateIndex(
            name: "IX_AbpBlobContainers_TenantId_Name",
            table: "AbpBlobContainers",
            columns: new[] { "TenantId", "Name" });

        migrationBuilder.CreateIndex(
            name: "IX_AbpBlobs_ContainerId",
            table: "AbpBlobs",
            column: "ContainerId");

        migrationBuilder.CreateIndex(
            name: "IX_AbpBlobs_TenantId_ContainerId_Name",
            table: "AbpBlobs",
            columns: new[] { "TenantId", "ContainerId", "Name" });
    }

    protected override void Down(MigrationBuilder migrationBuilder)
    {
        migrationBuilder.DropTable(
            name: "AbpBlobs");

        migrationBuilder.DropTable(
            name: "AbpBlobContainers");
    }
}
